<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const shapeOption = {
            // 不需要关心value值
            triangle: Symbol(),
            rectangle: Symbol()
        };

        function getArea(shape, options){
            let area = 0;

            switch(shape){
                // 直接使用字符串会和代码形成强耦合，不利于维护
                case shapeOption.triangle:
                    area = .5 * options.width * options.height;
                    break;
            }
            return area;
        }

        getArea(shapeOption.triangle, { width: 100, height: 100 });
    </script>
</body>
</html>